package com.zdx.yswl.ui.tool;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by lpw on 15-7-25.
 */

public class SqliteDBHelper extends SQLiteOpenHelper
{
    // 数据库名和表名
    public final static String dbName = "dbDevice";
    public final static String tableName = "tableDevice";
    public final static String tableNameUser = "tableUser";

    public SqliteDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version)
    {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db)
    {
        db.execSQL("create table " + tableName + "(deviceName char[20], userName char[20], " +
                   "pwd char[20], bind integer, tag char[40])");
        db.execSQL("create table " + tableNameUser + "(userName char[20])");
        Log.e("数据库", "表创建成功");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
    }

    public boolean deleteDatabase(Context context)
    {
        return context.deleteDatabase(dbName);
    }
}
